/**
 *  (c)
 * <p>
 *
 * <p>
 *
 */

package com.nn.smart.bus.feign;

import com.nn.smart.bus.commons.tools.constant.ServiceConstant;
import com.nn.smart.bus.commons.tools.security.user.UserDetail;
import com.nn.smart.bus.commons.tools.utils.Result;
import com.nn.smart.bus.feign.fallback.ResourceFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 资源接口
 *
 * @author nanning
 * @since 1.0.0
 */
@FeignClient(name = ServiceConstant.BUS_AUTH_SERVER, fallback = ResourceFeignClientFallback.class)
public interface ResourceFeignClient {

    /**
     * 是否有资源访问权限
     *
     * @param token  token
     * @param url    资源URL
     * @param method 请求方式
     * @return 有访问权限，则返回用户信息
     */
    @PostMapping("auth/resource")
    Result<UserDetail> resource(@RequestHeader(HttpHeaders.ACCEPT_LANGUAGE) String language, @RequestParam("token") String token,
                                @RequestParam("url") String url, @RequestParam("method") String method);
}
